//
//  CookMethodTableViewCell.m
//  Cook
//
//  Created by 0.0 on 15-4-15.
//  Copyright (c) 2015年 dingjun. All rights reserved.
//

#import "CookMethodTableViewCell.h"

@implementation CookMethodTableViewCell

- (void)dealloc
{
    [_backView release];
    [_cookImageView release];
    [_numLabel release];
    [_cookMethodLabel release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 375, 667);
        CGAdapter myAdapter = [AdapterModel getCGAdapter];
        
        self.contentView.backgroundColor = [UIColor colorWithRed:247 / 255.0 green:227 / 255.0 blue:171 / 255.0 alpha:1.0];
        
        self.backView = [[UIView alloc] initWithFrame:CGRectMake(30, 10, (self.frame.size.width - 60) * myAdapter.sWidth, 250 * myAdapter.sHeight)];
        self.cookImageView = [[UIImageView alloc] initWithFrame:CGRectMake(_backView.frame.origin.x + 5, _backView.frame.origin.y + 5, _backView.frame.size.width - 10, _backView.bounds.size.height - _backView.bounds.size.height / 4)];
     
        _cookImageView.layer.borderWidth = 0.05f;
        _cookImageView.layer.shadowOffset = CGSizeMake(0, 0);
        _cookImageView.layer.shadowColor = [UIColor grayColor].CGColor;
        _cookImageView.layer.shadowOpacity = 0.8;
        _cookImageView.layer.shadowRadius = 5.0f;
        
        self.cookMethodLabel = [[UILabel alloc] initWithFrame:CGRectMake(_cookImageView.frame.origin.x + 5, _cookImageView.frame.origin.y + _cookImageView.frame.size.height, _cookImageView.frame.size.width * myAdapter.sWidth,  (_backView.frame.size.height / 3) * myAdapter.sHeight)];
        
    
        _cookMethodLabel.font = [UIFont systemFontOfSize:15.0f];
        _cookMethodLabel.numberOfLines = 3;
        
        self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.origin.x + _cookImageView.frame.size.width * 1.05, _cookImageView.frame.origin.y + _cookImageView.frame.size.height + _cookMethodLabel.frame.size.height / 2, (_backView.frame.size.height / 5) * myAdapter.sWidth, (_backView.frame.size.height / 5) * myAdapter.sHeight)];
        self.numLabel.backgroundColor = [UIColor orangeColor];
        self.numLabel.layer.cornerRadius = _numLabel.frame.size.width / 2;
        self.numLabel.layer.masksToBounds = YES;
        self.numLabel.textAlignment = NSTextAlignmentCenter;
     
        
        self.frame = CGRectMake(_backView.frame.origin.x, _backView.frame.origin.y, _backView.frame.size.width * myAdapter.sWidth, _backView.frame.size.height + 50);
        [self.contentView addSubview:_backView];
        [self.contentView addSubview:_cookImageView];
        [self.contentView addSubview:_numLabel];
        [self.contentView addSubview:_cookMethodLabel];
        
        [_backView release];
        [_cookImageView release];
        [_cookMethodLabel release];
        [_numLabel release];
    }
    
    
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
